#include <iostream>
#include <vector>
#include <string>
using namespace std;

class Solution {
	int value(vector<int> &nums, int l, int r)
	{
		if (l == r) {
			return nums[l];
		}

		if (l + 1 == r) {
			return max(nums[l], nums[r]);
		}

		int p1 = nums[l] + min(value(nums, l + 2, r), value(nums, l + 1, r - 1));
		int p2 = nums[r] + min(value(nums, l + 1, r - 1), value(nums, l, r - 2));
		return max(p1, p2);
	}

	int first_sum(vector<int> &nums)
	{
		int n = nums.size();
		vector<vector<int>> dp(n, vector<int>(n, 0));
		for (int i = 0; i + 1 < n; i++) {
			dp[i][i] = nums[i];
			dp[i][i + 1] = max(nums[i], nums[i + 1]);
		}
		dp[n - 1][n - 1] = nums[n - 1];

		for (int col = 2; col < n; col++) {
			for (int l = 0, r = col; r < n; l++, r++) {
				int p1 = nums[l] + min(dp[l + 2][r], dp[l + 1][r - 1]);
				int p2 = nums[r] + min(dp[l + 1][r - 1], dp[l][r - 2]);
                                dp[l][r] = max(p1, p2);
			}
		}
                return dp[0].back();
	}

    public:
	bool predictTheWinner(vector<int> &nums)
	{
		int sum = 0;
		for (int i = 0; i < nums.size(); i++) {
			sum += nums[i];
		}

		//int first = value(nums, 0, nums.size() - 1);
                int first = first_sum(nums);
		return first >= (sum - first);
	}
};

int main()
{
	vector<int> nums = { 1, 5, 233, 7 };
	cout << Solution().predictTheWinner(nums) << endl;
	return 0;
}